<?php
/*============================================
|| PHP Example:	Tao trang upload Images		||
|| Coder:		Bui Quoc Huy				||
|| Email:		kenny@qhonline.info			||
|| Website:		http://www.qhonline.info	||
=============================================*/
$site="http://www.qhonline.info";
if(isset($_POST['ok_upload']))
{
	$num=$_GET['file'];
	echo "<h3>Demo Images Script - Copyright by QHOnline.Info</h3>";
	$conn=mysql_connect("localhost","root","") or die("can't connect your database");
	mysql_select_db("images",$conn);
	for($i=0; $i< $num; $i++)
	{
		move_uploaded_file($_FILES['img']['tmp_name'][$i],"data/".$_FILES['img']['name'][$i]);
		$url="data/".$_FILES['img']['name'][$i];
		$name=$_FILES['img']['name'][$i];
		$sql="insert into images(img_url,img_name) values('$url','$name')";
		mysql_query($sql);
		echo "Upload Thanh cong file <b>$name</b><br />";
		echo "<img src='$url' width='120' /><br />";
		echo "Images URL: <input type='text' name='link' value='$site/$url' size='35' /><br />";
		
	}
	mysql_close($conn);
}
else
{
	echo "Vui long chon hinh truoc khi truy cap vao trang nay";
}
?>